#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;
void Swap(int& a, int& b)
{
	if (a != b)
	{
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
}
void QuickSort(vector<int>& a, int left, int right)
{
	if (left >= right)
		return;
	int prev = left;
	int cur = prev + 1;
	int keyi = left;
	while (cur <= right)
	{
		if (a[cur] < a[keyi] && ++prev != cur)
		{
			Swap(a[cur], a[prev]);
		}
		cur++;
	}
	Swap(a[prev], a[keyi]);
	keyi = prev;
	QuickSort(a, left, keyi - 1);
	QuickSort(a, keyi + 1, right);
}

int main()
{
	vector<int> arr = { 0,1,2,5,3,2,54,5,3,2 };
	for (const auto& n : arr)
	{
		cout << n << " ";
	}
	cout << endl;
	QuickSort(arr,0,arr.size() - 1);

	for (const auto& n : arr)
	{
		cout << n << " ";
	}
	cout << endl;
	return 0;
}